window.addEventListener('load', function () {
    var regtel = /^1[3|4|5|7|8]\d{9}$/;  //手机号码的正则表达式
    var regqq = /^[1-9]\d{4,}$/; //QQ的正则表达式
    var regname = /^([\u4eeo-\u9fa5|a-zA-Z0-9]){2,8}$/;;  //昵称的正则表达式
    var regmsg = /^\d{6}$/; //验证码的正则表达式
    var regpwd = /^\w{6,16}/ //密码的正则表达式
    var tel = document.querySelector('#tel');
    var qq = document.querySelector('#qq');
    var nickname = document.querySelector('#nickname');
    var msg = document.querySelector('#msg');
    var pwd = document.querySelector('#pwd')
    var surepwd = document.querySelector('#surepwd')
    //验证用户输入是否正确
    regexp(tel, regtel)
    regexp(qq, regqq)
    regexp(nickname, regname)
    regexp(msg, regmsg)
    regexp(pwd, regpwd)
    function regexp(ele, reg) {
        ele.addEventListener('blur', function () {
            if (reg.test(this.value)) {
                this.nextElementSibling.className = 'success'
                this.nextElementSibling.innerHTML = ' <i class="success_icon"></i>'
            } else {
                this.nextElementSibling.className = 'error'
                this.nextElementSibling.innerHTML = ' <i class="error_icon"></i> 格式输入错误 '
            }
        })
    }
    surepwd.addEventListener('blur', function () {
        if (this.value == pwd.value) {
            this.nextElementSibling.className = 'success'
            this.nextElementSibling.innerHTML = ' <i class="success_icon"></i>'
        } else {
            this.nextElementSibling.className = 'error'
            this.nextElementSibling.innerHTML = ' <i class="error_icon"></i> 两次密码输入不一致 '
        }
    })

})
